#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>

void* func(void*);

int main(int argc,char** argv)
{
  pthread_t tid;
  pthread_attr_t attr;
  int ret = pthread_attr_init(&attr);
  if(ret != 0)
  {
    fprintf(stderr,"%s\n",strerror(ret));
    exit(-1);
  }
  
  ret = pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
  if(ret != 0)
  {
    fprintf(stderr,"%s\n",strerror(ret));
    exit(-1);
  }
  printf("1\n");
  ret = pthread_create(&tid,&attr,func,NULL);
  if(ret != 0)
  {
    fprintf(stderr,"%s\n",strerror(ret));
  }
  
  ret = pthread_join(tid,NULL);
  if(ret != 0)
  {
    fprintf(stderr,"%s\n",strerror(ret));
  }

  ret = pthread_attr_destroy(&attr);
  if(ret != 0)
  {
    fprintf(stderr,"%s\n",strerror(ret));
  }
  pthread_exit((void*)0);
}


void* func(void* num)
{
  printf("ni hao\n");
  return NULL;
}
